<?php
/**
 * Created by PhpStorm.
 * User: liu
 * Date: 2018/9/11
 * Time: 0:55
 */

namespace app\blog\controller;


use app\admin\model\blog\Post;
use app\common\controller\font\Base;

class Index extends Base
{
    protected $allow=['index'];
    public function initialize()
    {
        $this->model=new Post();
        parent::initialize();
    }
    public function index()
    {
        list($where,$offset,$limit,$order)=$this->buildParams();
        $rows=$this->model->where($where)
            ->order(['created'=>'desc'])
            ->withCount('comments')
            ->paginate($limit,false,[
                'query'=>$where
            ]);
        return $this->fetch('',['rows'=>$rows]);

    }
}